/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package asteroidmining1;

/**
 *
 * @author IVAN
 */
import java.awt.Rectangle;
import java.awt.Graphics;
import java.awt.Color;

public class Ball {

    private Rectangle location;
    private Color color;

    public Ball(int x, int y, int r) {
        location = new Rectangle(x - r, y - r, 2 * r, 2 * r);
        color = Color.YELLOW;
    }

    public void setColor(Color newColor) {
        color = newColor;
    }

    public int radius() {
        return location.width / 2;
    }

    public int x() {
        return location.x + radius();
    }

    public int y() {
        return location.y + radius();
    }

    public Rectangle region() {
        return location;
    }

    public void paint(Graphics g) {
        g.setColor(color);
        g.fillOval(location.x, location.y,
                location.width, location.height);
    }

    protected void moveTo(int x, int y) {
        location.setLocation(x - radius(), y - radius());
    }

    protected Color getColor() {
        return color;
    }
}